﻿using FluentNHibernate.Mapping;
using EntitiesAndMappings.Entities;

namespace EntitiesAndMappings.Mappings
{
    public class IngresoMap : ClassMap<Ingreso>
    {
        public IngresoMap()
        {
            Id(x => x.Id).GeneratedBy.Native();
            References(x => x.TipoMovimiento).LazyLoad(Laziness.False).Not.Nullable();
            Map(x => x.Fecha).Not.Nullable();
            References(x => x.Proveedor).LazyLoad(Laziness.False).Nullable();
            Map(x => x.NumeroFactura).Length(50).Not.Nullable();
            Map(x => x.NumeroGuia).Length(50).Not.Nullable();
            References(x => x.Almacen).LazyLoad(Laziness.False).Nullable();
            References(x => x.Proyecto).LazyLoad(Laziness.False).Nullable();
            References(x => x.Lote).LazyLoad(Laziness.False).Nullable();
            References(x => x.Lugar).LazyLoad(Laziness.False).Nullable();
            Map(x => x.Ubicacion).Nullable();
            HasMany(x => x.Items).Cascade.AllDeleteOrphan();        
        }
    }
}
